$(function() {
    $.ajaxSetup({
        type: "post",
        dataType: "json"
    });

    $(".signin-submit").on("click", function(e) {
        e.preventDefault();

        var username = $("#user-name").val();
        var password = $("#user-passwd").val();

        var url = "/cms2/signin",
            data = {
                username: username,
                password: password
            };

        $.ajax({
            url: url,
            data: data,
            success: function(res) {
                if(res.ret == 0) {
                    window.location.href = "/cms2/topic";
                } else {
                    alert(res.msg);
                }
            }
        });
    });
});
